home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
L' Effet Pommier 3
/
L'Effet Pommier - Volume 03.iso
/
Communication
/
Digester 2.1.1b
/
sources
/
post-send.c
< prev
Wrap
Text File
|
1996-01-15
|
4KB
|
146 lines
/*
file: post-send
by: A.C. van der Ham
e-mail: a.c.vanderham@et.tudelft.nl
purpose: to be used together with digester to enable easy reply to messages
warning: only works with UNIX servers for now
where: compile it and put it in your html scripts directory
notice: don't forget to set the correct path for the info-mac files
*/
#define PATH "/home/vdham/Mosaic/info-mac/"
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#define MAXLINE 512
#define OK 0
#define ERROR 1
#define ITEMTEXT "<a name=item%d"
#define INFOMAC "info-mac@sumex-aim.stanford.edu"
#define EOM "<a name=item"
int findmessage( int item, char *file )
{
FILE *inP;
char line[256], searchString[100], address[80], *cptr;
strcpy( line, PATH );
strcat( line, file );
searchString[0]=0;
sprintf( searchString, ITEMTEXT, item );
strcpy( address, INFOMAC );
if( (inP = fopen( line, "r" )) != NULL )
{
do {
fgets( line, 256, inP );
} while( (!feof(inP)) &&
(strstr(line, searchString)==NULL) );
if( feof(inP) )
return(ERROR);
fputs( "<pre>", stdout );
do {
fgets( line, 256, inP );
if( (strstr(line,"<")==NULL) && (strstr(line,">")==NULL) )
fputs( line, stdout );
if( (cptr=strstr( line, "From: " ))!=NULL )
{
if( strstr(line, "mailto:")!=NULL )
{
cptr=strstr(line, "mailto:")+strlen("mailto:");
strcpy(address, cptr);
if((cptr=strstr(address, ">"))!=NULL)
*cptr=0;
}
else
{
cptr += 6;
strcpy(address, cptr);
if( (cptr=strstr(address,"\n")) != NULL)
*cptr=0;
if( (cptr=strstr(address,"<")) != NULL)
{
strcpy(address, cptr+4);
if( (cptr=strstr(address,">")) != NULL)
*cptr=0;
}
if( (cptr=strstr(address," ")) != NULL)
*cptr=0;
}
}
} while( (!feof(inP)) &&
(strstr(line, EOM)==NULL) );
fputs( "</pre>", stdout );
fprintf( stdout, "Reply to: <a href=mailto:%s>%s</a><p>\n", address, address );
fprintf( stdout, "Reply to: <a href=mailto:%s>%s</a><p>\n", INFOMAC, INFOMAC );
fclose(inP);
}
else
{
return(ERROR);
}
return(OK);
}
int main( int argc, char *argv[] )
{
char *cptr;
char file[80];
int item=0;
argc=argc;
fprintf(stdout, "Content-type: text/html\n\n");
if( argv[1]!=NULL)
{
if((cptr=strstr(argv[1],","))!=NULL)
{
*cptr=0;
item=atoi(argv[1]);
strcpy(file, cptr+1);
if( findmessage( item, file ) == ERROR)
{
fprintf(stdout, "<title>can't find message</title>\n");
fprintf(stdout, "Sorry, something went wrong in message selection.<p>\n");
fprintf(stdout, "Please notify: <a href=mailto:a.c.vanderham@et.tudelft.nl>André van der Ham</a>.<p>\n");
fprintf(stdout, "ERROR: can't find message?!\n");
}
}
else
{
fprintf(stdout, "<title>no delimiter</title>\n");
fprintf(stdout, "Sorry, something went wrong in message selection.<p>\n");
fprintf(stdout, "Please notify: <a href=mailto:a.c.vanderham@et.tudelft.nl>André van der Ham</a>.<p>\n");
fprintf(stdout, "ERROR: File name delimiter not found?!\n");
}
}
else
{
fprintf(stdout, "<title>no arguments</title>\n");
fprintf(stdout, "Sorry, something went wrong in message selection.<p>\n");
fprintf(stdout, "Please notify: <a href=mailto:a.c.vanderham@et.tudelft.nl>André van der Ham</a>.<p>\n");
fprintf(stdout, "ERROR: Can't find any arguments to query?!\n");
}
return(0);
}